<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="../head.jsp"%>
<%@ include file="../kindeditor.jsp"%><!-- kindeditor -->
<body>
<%@ include file="../navbar.jsp"%><!--导航 -->
<div class="container widget">
	<div class="toolbar text-right"></div>
	<div class="">
		<form id="recruitInfo" action="${ctx}/recruit/addRecruit" class="form-horizontal" role="form" method="post">
			<div class="form-group">
				<label for="firstname" class="col-xs-2 control-label">名称</label>
			     <div class="col-xs-8">
			     	<input type="text" class="form-control" name="recruitName" maxlength="50" placeholder="请输入名称">
			     </div>
			</div>
			<div class="form-group">
				<label for="firstname" class="col-xs-2 control-label">副名称</label>
			     <div class="col-xs-8">
			     	<input type="text" class="form-control" name="recruitSubName" maxlength="50" placeholder="请输入副名称">
			     </div>
			</div>
			<div class="form-group">
				 <label for="firstname" class="col-xs-2 control-label">标题</label>
			     <div class="col-xs-8">
			     	<input type="text" class="form-control" name="recruitTitle" maxlength="100" placeholder="请输入标题">
			     </div>
			</div>
			<div class="form-group">
				<label for="firstname" class="col-xs-2 control-label">排序号</label>
			     <div class="col-xs-8">
			     	<input type="text" class="form-control" name="sort" placeholder="请输入排序号"  maxlength="3" onkeyup="value=value.replace(/[^0-9]/gi,'')">
			     </div>
			</div>
			<div class="form-group">
				<label for="firstname" class="col-xs-2 control-label">招聘内容</label>
			     <div class="col-xs-8">
			     	<textarea id="recruitContent" name="recruitContent" style="width:800px;height:240px;visibility:hidden;"></textarea>
			     </div>
			</div>
			<div class="form-group">
		      <div class="col-xs-offset-2 col-xs-10">
		         <input type="text" class="btn btn-info" id="save_btn" value="保存"/>
		      </div>
		   </div>
		</form>
	</div>
	
</div>

<script type="text/javascript">
	document.title = "德燊后台-招聘新增";
	var editor;
	KindEditor.ready(function(K) {
		editor = K.create('#recruitContent', {
			resizeType : 1,//设置可否改变编辑器大小0:不能改变 1:只能改变高度 2:宽度和高度都可以改变（默认） 
			uploadJson : '${ctx}/upload.do',
	        fileManagerJson : '${ctx}/fileManager.do',
			allowImageUpload : true,
			items : [
				'source', '|', 'preview', '|', 'formatblock', 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold', 'italic', 'underline',
				'lineheight', 'removeformat', '|', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist',
				'insertunorderedlist', '|', 'emoticons', 'image', 'link']
		});
	});
	$(function(){
		var rstCode = '${resultCode}';
		var rstMsg = '${resultMsg}';
		if(rstCode != "" && rstMsg != ""){
			if(rstCode == 1){
				alert(rstMsg);
				location.href = "${ctx}/recruit/findRecruit";
			}else if(rstCode == 0){
				alert(rstMsg);
			}
		}
	}); 
	/* 保存 */
	$("#save_btn").click(function(){
		editor.sync();// 同步数据后可以直接取得textarea的value
		var recruitName = $.trim($("input[name='recruitName']").val());
		if(recruitName == ""){
			alert("请输入名称");
			return;
		}
		var recruitSubName = $.trim($("input[name='recruitSubName']").val());
		if(recruitSubName == ""){
			alert("请输入副名称");
			return;
		}
		var recruitTitle = $.trim($("input[name='recruitTitle']").val());
		if(recruitTitle == ""){
			alert("请输入标题");
			return;
		}
		var sort = $.trim($("input[name='sort']").val());
		if(sort == ""){
			alert("请输入排序号");
			return;
		}
		var recruitContent = $.trim($("#recruitContent").val());
		if(recruitContent == ""){
			alert("请输入招聘内容");
			return;
		}
		$("#recruitInfo").submit();
	});
</script>
</body>

